﻿using FluentAPI.Entity;
using FluentAPI.Entity.ComplexRelationship;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FluentAPI
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var BlogContext = new BlogEFContext())
            {
                //BlogContext.Blogs.Add(new Blog()
                //{
                //    Name = "Tom1",
                //    url = "Mayt.cn"
                //}
                //);
                //BlogContext.Order.Add(new Entity.ComplexRelationship.Order()
                //{
                //    ID = 3,
                //    Name = "电商",
                //    address = new Address()
                //}

                //);
                // 客户和订单对多关系
                //var customer = new Customer()
                //{
                //    Name = "matao",
                //    Email = "tom@39cn.net",
                //    CreatedTime = DateTime.Now,
                //    ModifiedTime= DateTime.Now,
                //    Orders = new List<Entity.Order>()
                //    {
                //        new Entity.Order (){  Quantity=12,Price=10,CreatedTime=DateTime.Now,ModifiedTime=DateTime.Now},
                //        new Entity.Order (){  Quantity=22,Price=20,CreatedTime=DateTime.Now,ModifiedTime=DateTime.Now}

                //    }

                //};


                //BlogContext.Customer.Add(customer);

                var student = new Student()
                {
                    Name = "Tom",
                    Age = 30,
                    CreatedTime = DateTime.Now,
                    ModifiedTime = DateTime.Now,
                    Courses = new List<Course>()
                    {
                        new Course()
                        {
                            Name ="c#" ,
                            CreatedTime = DateTime.Now,
                            ModifiedTime= DateTime.Now,
                        },
                        new Course()
                        {
                            Name ="java",
                            CreatedTime = DateTime.Now,
                            ModifiedTime= DateTime.Now,},

                    }

                };
                var Course = new Course()
                {
                    Name = "web",
                    CreatedTime = DateTime.Now,
                    ModifiedTime = DateTime.Now,
                    Students = new List<Student>() {
                        new Student()
                        {
                            Name ="jessie",
                            CreatedTime = DateTime.Now,
                             ModifiedTime= DateTime.Now,
                        },
                        new Student()
                        {
                            Name ="jack",
                            CreatedTime = DateTime.Now,
                            ModifiedTime= DateTime.Now,
                        },
                    }

                };
                BlogContext.Student.Add(student);
                BlogContext.Course.Add(Course);

                BlogContext.SaveChanges();
            }
        }
    }
}
